<template>
	<view class="value" :style="{height: Height+'px'}">
		<view class="">
			<view v-if="!isNull" class="header box d-ai-c d-jc-sb">
				<view class="" style="color: #333333;">
					综合评分：{{userInfo.userInfo.userAccompanyInfo.grade}}
				</view>
				<view class="example-body ml-2">
					<uni-rate size="23" :margin="5" active-color="#FF8338" :value="userInfo.userInfo.userAccompanyInfo.grade" :readonly="true"/>
				</view>
			</view>
			<scroll-view :refresher-triggered=refresherTriggered :refresherThreshold=refresherThreshold
					@refresherrefresh='refresherrefresh()' refresher-background="#FFFFFF"  @scrolltolower='nextPage()'
					 
					 lower-threshold="500" class="" scroll-y>
			<view v-if="!isNull" class="content" v-for="(item,index) in value" :key="index">
				<view class="box d-ai-c d-jc-sb evalue">
					<uni-rate size="18" :readonly="true" :margin="5" active-color="#FF8338" :value="item.grade" />
					<view class="">
						{{item.createTime}}
					</view>
				</view>
				<view class="valuecontent">
					{{item.content}}
				</view>
			</view>
			<view v-if="isNull" class="order_null">
				<image src="../../static/wupingjia@2x.png"></image>
				<text>暂时还没有评价~</text>
				<!-- <button class="btn-shop-list" @tap='shopList()'>去逛逛</button> -->
			</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				Height:400,
				rateValue:5,
				value:'',
				isNull:false,
				hasNextPage:false,
				pageNum:1,
				pageSize:10,
			}
		},
		computed: mapState(['loginState', 'userInfo']),
		onReady() { 
			let that = this;
			uni.getSystemInfo({ //调用uni-app接口获取屏幕高度
				success(res) { //成功回调函数
					that.Height = res.windowHeight - uni.upx2px(0) //windoHeight为窗口高度，主要使用的是这个
				}
			})
		},
		onShow() {
				this.userevaluate()
				this.getUserInfo()
		},
		methods: {
			...mapMutations(['login', 'logout','setUserInfo']),
			// 获取用户信息
			getUserInfo() {
				this.$api.getUserInfo().then((res) => {
					let userInfo = res.data.dataMap
					// this.getUserIn = res.data.dataMap
					console.log(userInfo)
					if (userInfo != null) {
						this.setUserInfo(userInfo)
					}
			
				})
			
			},
			nextPage() {
				console.log("====出发底部===")
				console.log("====出发底部===" + this.pageNum)
				console.log("====出发底部===" + this.hasNextPage)
				if (this.hasNextPage) {
					this.pageNum = this.pageNum + 1
					this.$api.userevaluate({
						accompanyId:this.userInfo.userInfo.userAccompanyInfo.accompanyId,
						status:this.status
					}, this.pageNum, this.pageSize).then((res) => {
						if (res.data.code == 200) {
							for (var i = 0; i < res.data.dataMap.list.length; i++) {
								this.value.push(res.data.dataMap.list[i])
							}
							this.hasNextPage = res.data.dataMap.hasNextPage
			
						}
					})
				}
			
			},
			userevaluate() {
				this.$api.userevaluate({
					accompanyId:this.userInfo.userInfo.userAccompanyInfo.accompanyId
				},this.pageNum, this.pageSize).then((res) => {
					if(res.data.success){
						console.log(res.data.dataMap)
						this.value = res.data.dataMap.list
						this.hasNextPage = res.data.dataMap.hasNextPage
						this.isNull = this.value.length < 1 ? true : false
					}else{
						uni.showToast({
							title:res.data.message,
							icon:'none',
							duration:1000
						})
					}
			
				})
			
			},
		}
	}
</script>

<style scoped lang="less">
	.order_null {
		display: flex;
		width: 100%;
		flex-direction: column;
	}
	
	.order_null text {
		margin: 0 auto;
		color: #c8c8c8;
	}
	
	.order_null image {
		margin: 0rpx auto;
		margin-top: 150rpx;
		width: 420rpx;
		height: 272rpx;
	}
	.value{
		background: #F2F7FF;
		.header{
			width: 690rpx;
			height: 110rpx;
			padding: 0 30rpx;
			background: #FFFFFE;
		}
	}
	.content{
		width: 630rpx;
		padding: 30rpx;
		background-color: #FFFFFF;
		margin: 0 auto;
		margin-top: 30rpx;
		.evalue{
			view{
				font-size: 28rpx;
				font-weight: 500;
				color: #999999;
			}
		}
		.valuecontent{
			padding-top: 20rpx;
			font-size: 28rpx;
			font-weight: 500;
			color: #999999;
		}
	}
</style>
